package app.itgungnir.compose.wan.theme

import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import kotlin.math.sqrt

class MineBackgroundShape : Shape {
    override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
        val width = size.width
        val height = size.height
        val circleR = (width * sqrt(1.25)).toFloat()
        val path = Path().apply {
            lineTo(width, 0F)
            lineTo(width, height / 2)
            arcTo(
                rect = Rect(
                    left = width / 2 - circleR,
                    top = height / 2 - width - circleR,
                    right = width / 2 + circleR,
                    bottom = height / 2 - width + circleR
                ),
                startAngleDegrees = 60F,
                sweepAngleDegrees = 60F,
                forceMoveTo = false
            )
        }
        return Outline.Generic(path)
    }
}
